package com.itheima.admin.controller;

import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import com.itheima.admin.service.AdUserService;
import com.itheima.common.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/login")
@Api(tags = "后台管理系统登录")
public class LoginController {
    @Autowired
    private AdUserService adUserService;

    @PostMapping("/in")
    @ApiOperation("登录")
    @DynamicParameters(name = "JSON",properties={
            @DynamicParameter(name = "name", value = "登录用户名", required = true),
            @DynamicParameter(name="password", value = "密码", required = true)
    })
    public ResultVo<Map<String,Object>> login(@RequestBody Map<String,String> loginParams){
        Map<String,Object> resultMap = adUserService.loginCheck(loginParams);
        return ResultVo.ok(resultMap);
    }
}
